package com.celan.year2023.month05.day31;

/**
 * @author Celan
 * @description TODO
 */
class Solution {
    // 1 + 1 = 10
    // 1 + 0 = 01
    // 0 + 1 = 01
    // 0 + 0 = 00
    // =>
    // carry << 1 + (a + b)
    // (a & b) << 1 + a ^ b
    public int getSum(int a, int b) {
        while (b != 0) {
            int carry = (a & b) << 1;
            a = a ^ b;
            b = carry;
        }
        return a;
    }
}
